< previous page page_336 next page >

Page 336
Chapter Objectives
Learn error-handling techniques
Learn the different methods for handling errors
Utilize the Err object
Create a generic error handler
Sample Project File: \Chapter17\Errors.vbp
How Visual Basic Handles Error
If Visual Basic detects an error in your program, youll see a dialog box appear that tells you what the error is and allows you to go into debug mode, end the program, or get help. As you can see from looking at Figure 17.1, this dialog box is not very descriptive, and it wont give the user a clue as to how to handle this error. As a result, youll probably want to add your own error handling to your applications.
9f31265bb40b592b1929e18a47ab28e5.gif
NOTE
Only when youre running from the Visual Basic development environment will you have all the command buttons shown in Figure 17.1. If youve created an EXE file, the only button you have to respond to is the OK button. When you click this button, the Visual Basic program will end very abruptly.
8160-0336a.gif
Figure 17.1
The Visual Basic error dialog box.
You can see this error dialog box by running the sample project for this chapter and clicking the Divide Error command button and then clicking the VBError command button on the Divide By Zero form.

 
< previous page page_336 next page >

If you like this book, buy it!